import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;

public class StepOne {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
//        String inputPath = args[0];
//        String outputTable = args[1];

        Configuration conf = HBaseConfiguration.create();
        Path path = new Path("./tmp_1");
        Job job = Job.getInstance(conf);
        job.setJarByClass(StepOne.class);
        job.setJobName("倒排索引step1");
        job.setMapperClass(MyMapper.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

        job.setReducerClass(MyReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        FileInputFormat.setInputPaths(job, new Path("./input"));
        FileInputFormat.setInputDirRecursive(job, true);
        FileOutputFormat.setOutputPath(job, path);

//        TableMapReduceUtil.initTableReducerJob("index", MyReducer.class, job);
        System.out.println(job.waitForCompletion(true));
    }
}
